CREATE TABLE [dbo].[TCFACT_PRME]
(
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[CO_MONE_BASE] [dbo].[TD_VC_003] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANOS] NOT NULL CONSTRAINT [DF__TCFACT_PR__NU_AN__07020F21] DEFAULT (datepart(year,getdate())),
[NU_MESE] [dbo].[TD_IN_002_MESE] NOT NULL,
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[FA_CAMB_VNTA] [dbo].[TD_NU_015_006] NOT NULL CONSTRAINT [DF__TCFACT_PR__FA_CA__09DE7BCC] DEFAULT ((0)),
[FA_CAMB_CMPR] [dbo].[TD_NU_015_006] NOT NULL CONSTRAINT [DF__TCFACT_PR__FA_CA__0AD2A005] DEFAULT ((0)),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NULL CONSTRAINT [DF__TCFACT_PR__CO_US__0BC6C43E] DEFAULT (substring(suser_sname(),(1),(8))),
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NULL CONSTRAINT [DF__TCFACT_PR__FE_US__0CBAE877] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NULL CONSTRAINT [DF__TCFACT_PR__CO_US__0DAF0CB0] DEFAULT (substring(suser_sname(),(1),(8))),
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NULL CONSTRAINT [DF__TCFACT_PR__FE_US__0EA330E9] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCFACT_PRME] WITH NOCHECK ADD CONSTRAINT [CK__TCFACT_PR__NU_AN__07F6335A] CHECK NOT FOR REPLICATION (([NU_ANNO]>(1850)))
GO
ALTER TABLE [dbo].[TCFACT_PRME] WITH NOCHECK ADD CONSTRAINT [CK__TCFACT_PR__NU_ME__08EA5793] CHECK NOT FOR REPLICATION (([NU_MESE]>=(0) AND [NU_MESE]<=(12)))
GO
ALTER TABLE [dbo].[TCFACT_PRME] ADD CONSTRAINT [PK__TCFACT_P__C7CB7D505555A4F4] PRIMARY KEY CLUSTERED  ([CO_MONE], [CO_MONE_BASE], [NU_ANNO], [NU_MESE], [CO_EMPR]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [ICFACT_PRME_I02] ON [dbo].[TCFACT_PRME] ([NU_MESE]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCFACT_PRME] ADD CONSTRAINT [FK__TCFACT_PR__CO_EM__1E8F7FEF] FOREIGN KEY ([CO_EMPR]) REFERENCES [dbo].[TMEMPR] ([CO_EMPR])
GO
ALTER TABLE [dbo].[TCFACT_PRME] ADD CONSTRAINT [FK__TCFACT_PRME__1D9B5BB6] FOREIGN KEY ([CO_MONE], [CO_MONE_BASE]) REFERENCES [dbo].[TMFACT_CAMB] ([CO_MONE], [CO_MONE_BASE])
GO
GRANT SELECT ON  [dbo].[TCFACT_PRME] TO [public]
GRANT INSERT ON  [dbo].[TCFACT_PRME] TO [public]
GRANT DELETE ON  [dbo].[TCFACT_PRME] TO [public]
GRANT UPDATE ON  [dbo].[TCFACT_PRME] TO [public]
GO
